﻿<div class="page-content-wrap">
    <div class="layui-form" id="table-list" style="height: 400px;">
        <table id="list" class="layui-table"></table>
    </div>
</div>
@section script{
<script>
    $("#list").datagrid({
        idField: 'id',
        //singleSelect: false,
        //rownumbers: true,
        pagePosition: 'bottom',
        pagination: true,//分页
        pageSize: 100,//每页显示条数
        pageList: [100, 150, 200, 250, 300, 350], //调整每页显示条数
        fit: true,//宽高跟随父面板
        fitColumns: true,//水平滚动条
        nowrap: false,//折行显示
        columns: [[
            { field: 'check', checkbox: true, width: 100, align: 'center' },
            { field: 'wOno', title: '工单编号', width: 100, align: 'center' },
            { field: 'wOname', title: '工单名称', width: 180, align: 'center' },
            { field: 'email', title: '客户邮箱', width: 180, align: 'center' },
            { field: 'describe', title: '描述', width: 180, align: 'center' },
            {
                field: 'edit', title: '编辑', width: 180, align: 'center',
                formatter: function (value, row, index) {
                    return '<button class="layui-btn layui-btn-mini layui-btn-normal edit_btn" data-id="' + row.email + '" data-url="'+row.wOname+'"><i class="layui-icon">&#xe642;</i>回复</button>' +
                        '<button class="layui-btn layui-btn-mini layui-btn-danger del_btn" data-id="' + row.wOno + '" data-url="/Home/DeleteWork"><i class="layui-icon">&#xe640;</i>删除</button>';
                }
            }
        ]],
        url: '/Home/WorkTable',
    })
    layui.use(['form'], function () {
        var form = layui.form();
        form.render();
    });
    $('#table-list').on('click', '.edit_btn', function () {
        var That = $(this);
        var id = That.attr('data-id');
        var url = That.attr('data-url');
        //将iframeObj传递给父级窗口
        layer.open({
            type: 2,
            title: ["回复客户信息"],
            area: ['600px', '500px'],
            content: "/Home/EditWork" + "?emaill=" + id+"&title=关于‘"+url+"’的回复！", //这里content是一个URL，如果你不想让iframe出现滚动条，你还可以content: ['http://sentsin.com', 'no']
            cancel: function () {
                location.reload();
            }
        });
        return false;
    })
    //列表删除
    $('#table-list').on('click', '.del_btn', function () {
        var url = $(this).attr('data-url');
        var no = $(this).attr('data-id');
        layer.confirm('您确定要删除选中项?', function (index) {
            //do something
            $.ajax({
                type: "post",
                url: url,
                data: { no: no },
                // dataType: 'Json',
                // async:true,
                success: function (result) {
                    parent.layer.msg(result);
                    window.reload();
                }
            });
            layer.close(index);
        });
        return false;
    })
</script>

}